<?php

namespace Weapp\Shop;

use Weapp\Basic\Basic;



/**
 * 小程序自定义交易组件，申请接入接口
 * Class Register
 * @package Weapp/Shop
 * @url https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent2/API/enter/enter_apply.html
 */
class Register extends Basic
{
    /**
     * 开通自定义版交易组件，将同步返回接入结果，不再有异步事件回调
     * @param array $data
     * @return array
     * @throws \Weapp\Exceptions\InvalidResponseException
     * @throws \Weapp\Exceptions\LocalCacheException
     */
    public function apply($data)
    {
        $url = 'shop/register/apply';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, $data, true);
    }

    /**
     * 获取接入状态 如果账户未接入，将返回错误码1040003
     * @param array $data
     * @return array
     * @throws \Weapp\Exceptions\InvalidResponseException
     * @throws \Weapp\Exceptions\LocalCacheException
     */
    public function check($data)
    {
        $url = 'shop/register/check';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, $data, true);
    }

    /**
     * 完成接入任务
     * @param array $data
     * @return array
     * @throws \Weapp\Exceptions\InvalidResponseException
     * @throws \Weapp\Exceptions\LocalCacheException
     */
    public function finish($data)
    {
        $url = 'shop/register/finish_access_info';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, $data, true);
    }

    /**
     * 场景接入申请
     * @param array $data
     * @return array
     * @throws \Weapp\Exceptions\InvalidResponseException
     * @throws \Weapp\Exceptions\LocalCacheException
     */
    public function apply_scene($data)
    {
        $url = 'shop/register/apply_scene';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, $data, true);
    }
}
